
import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk

from PiaoXingQiuRequest import config


def on_button_click():
    # 更改按钮的文本
    if(start_button['text'] == '运行中'):
        start_button.config(text='开始')
        config.continue_buy = False
    else:
        start_button.config(text='运行中')
        # start_buy()
    # 在这里可以执行其他你需要的操作
# 创建主窗口
root = tk.Tk()
root.title("简单的GUI界面")

# 加载图片
image_path = "piao_xing_qiu.png"  # 图片路径，请替换为实际路径
try:
    img = Image.open(image_path)
    img.thumbnail((100, 100))  # 调整图片大小以适应界面
    photo_img = ImageTk.PhotoImage(img)
except FileNotFoundError:
    print("未找到图片文件")
    exit(1)

# 图片标签
image_label = tk.Label(root, image=photo_img)
image_label.grid(row=0, column=0, columnspan=3, pady=(10, 5))

# 节目标签和输入框
program_label = tk.Label(root, text="节目:")
program_label.grid(row=1, column=0, sticky="e", padx=(10, 5), pady=5)
program_entry = ttk.Entry(root, width=20)
program_entry.grid(row=1, column=1, padx=5, pady=5, sticky="ew")

# 输入框及提示文案
entry1_label = tk.Label(root, text="场次:")
entry1_label.grid(row=2, column=0, sticky="e", padx=(10, 5), pady=5)
entry1 = ttk.Entry(root, width=20)
entry1.grid(row=2, column=1, padx=5, pady=5, sticky="ew")

entry2_label = tk.Label(root, text="票价:")
entry2_label.grid(row=3, column=0, sticky="e", padx=(10, 5), pady=5)
entry2 = ttk.Entry(root, width=20)
entry2.grid(row=3, column=1, padx=5, pady=5, sticky="ew")

# 扩展开始按钮高度
start_button = ttk.Button(root, text="开始", command=on_button_click)
start_button.grid(row=1, column=2, rowspan=3, columnspan=1, padx=5, pady=5, sticky="nsew")

# 提示文本
info_label = tk.Label(root, text="点击开始后会自动抢票\n选座类需预填")
info_label.grid(row=4, column=1, sticky="w", padx=0, pady=5)
# 运行主循环
root.mainloop()

